Ten pixels in a row will be set to red. This will look like a short, horizontal, red line on the upper left of the screen.
In computer graphics,
a line is made by setting many adjacent pixels to the same color.
You could draw a line by using the PSET
statement many times.
But there is an easier way.
To draw a line of pixels all of the
same color use the LINE
statement:
LINE (startX, startY)-(endX, endY)
This statement:
Here is a program that does the same as the previous
program, except using a LINE
statement:
' Setting 10 pixels in row 3 ' to color 4 (Red) ' SCREEN 12 COLOR 4 LINE (1, 3) - (10, 3) ' draw a line from (1,3) to (16,3) END
The program is much shorter than the one that uses PSET
.
The picture on the graphics screen will look like this
(slightly enlarged):
The upper left corner of graphics screen 12 is (x=0, y=0); the lower right corner of the screen is (x=639, y=479). Write a program that draws a red diagonal line from the upper left corner to the lower right corner.